package com.qf.cx.simplenms.reader.tag;

import java.util.Collections;
import java.util.Map;

import com.qf.cx.simplenms.reader.model.AntennaModel;
import com.qf.cx.simplenms.reader.tag.Tag.ReadOpResult;
import com.qf.cx.simplenms.tagmemory.model.TagMemoryModel.Identifier;

/**
 * 表示天线 上报的标签，天线和tid相同表示同一个标签
 * 
 * @author wanghaoming
 *
 */
public class AntennaTag {
	private AntennaModel antenna;
	private Tag tag;
	private final Statistic statistic;

	public AntennaTag() {
		statistic = new Statistic();
		statistic.setCount(1);
	}

	public void mergeStatistic(Statistic statistic) {
		this.statistic.mergeStatistic(statistic);
	}

	public Statistic getStatistic() {
		return statistic;
	}

	public AntennaModel getAntenna() {
		return antenna;
	}

	public void setAntenna(AntennaModel antenna) {
		this.statistic.setAnt(antenna.getAntennaNo());
		this.statistic.setReader(antenna.getReaderName());
		this.antenna = antenna;
	}

	public Tag getTag() {
		return tag;
	}

	public void setTag(Tag tag) {
		this.tag = tag;
	}

	public Map<Identifier, ReadOpResult> getReadOpResults() {
		if (tag == null) {
			return Collections.emptyMap();
		}
		return tag.getReadOpResults();
	}

	public String getTid() {
		if (tag == null) {
			return null;
		}
		return tag.getTid();
	}

	@Override
	public String toString() {
		return "AntennaTag [antenna=" + antenna + ", tag=" + tag + ", statistic=" + statistic + "]";
	}

}